package com.camel;

import org.apache.camel.Exchange;
import org.apache.camel.processor.aggregate.AggregationStrategy;

public class StringAggregator implements AggregationStrategy {

	public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
		if(oldExchange != null) {
			Exchange aggregatedExchange = null;
			String str = (String)oldExchange.getIn().getBody() + "," + (String)newExchange.getIn().getBody(); 
			aggregatedExchange = oldExchange.copy();
			aggregatedExchange.getIn().setBody(str);
			return aggregatedExchange;
		}
		return newExchange;
	}
}
